package com.example.demo.class15_并查集;

/**
 * @program: java_base
 * @description:
 * @author: zhouhongtao
 * @happyCreateTime: 2022/03/01 16:19
 */


/**
 * 某公司面试题：
 公司A想要在大饭店组织一场年会，邀请所有员工参加
 因为疫情原因，饭店的每一张桌子最多只能坐x个员工, 比如在新加坡，x=8. 我们可以假设所有桌子都可以坐x人
 因为公司太大，员工数量太多，我们需要写个程序来分配桌子座位。
 每个桌子需要生成一个label （包含员工姓名等信息），发给餐馆用于制作座位牌，方便员工入座。
 例：Barak Obama(M), Hilary Clinton(F), Donald Trump(M)
 公司组织结构是树形的，CEO是这棵树的根。

 */
public class NameDBProcessor {

    // This method allocate tables for staff and subordinates, recursively
    //     and generate table information and store them in the database.
//    public void processstaff(Staff staff) {
//        for (Iterator<Staff> iterator = staff.subordinates.iterator(); iterator.hasNext();) {
//            Staff subordinate = iterator.next();
//            StaffInfo staffInfo = staffInfoDAO.getByStaffId(subordinate.getStaffId());
//            if (staffInfo.getGender() == "MALE") {
//                // this staff is MALE
//                String staffName = staffInfo.getName();
//                staffName = staffName + "(M)";
//                // replace "," in the name so that it does not look like two persons.
//                staffName = staffName.replace(",", " ");
//                currentTable.setSize(currentTable.getSize() + 1);
//                currentTable.getStaffIds().add(staffInfo.getStaffId());
//                if (currentTable.getLabel() == "") {
//                    // it comes the first element of this table.
//                    currentTable.setLabel(staffName);
//                } else {
//                    currentTable.setLabel(currentTable.getLabel() + ", " + staffName);
//                }
//            } else {
//                // this staff is FEMALE
//                String staffName = staffInfo.getName();
//                staffName = staffName + "(F)";
//                // replace "," in the name so that it does not look like two persons.
//                staffName = staffName.replace(",", " ");
//                currentTable.setSize(currentTable.getSize() + 1);
//                currentTable.getStaffIds().add(staffInfo.getStaffId());
//                if (currentTable.getLabel() == "") {
//                    // it comes the first element of this table.
//                    currentTable.setLabel(staffName);
//                } else {
//                    currentTable.setLabel(currentTable.getLabel() + ", " + staffName);
//                }
//            }
//            // the current table is full, save this table and open another table;
//            if (currentTable.getSize() == currentTable.capacity) {
//                tableDAO.recordTable(currentTable);
//                currentTable = new Table();
//            }
//            processstaff(subordinate);
//        }
//    }
//
//    // TableDAO writes table info to database
//    // interface TableDAO {
//    //     public void recordTable(Table table)
//    // }
//    static public TableDAO tableDAO;
//
//    // StaffInfoDAO read staff information from database.
//    // interface StaffInfoDAO {
//    //     public StaffInfo getByStaffId(String staffId)
//    // }
//    static public StaffInfoDAO staffInfoDAO;
//
//    public Table currentTable;
//
//    class Staff {
//        String staffId;
//        List<Staff> subordinates;
//    }
//
//    class StaffInfo {
//        // unique id of a staff
//        String staffId;
//        // name of the staff
//        String name;
//        // MALE or FEMALE
//        String gender;
//    }
//
//    class Table {
//        int capacity = 8;
//        List<String> staffIds;
//        // table label are formed by staff label and gender, separated by ", "
//        // example of a valid label: "Barak Obama(M), Hilary Clinton(F), Donald Trump(M)"
//        String label;
//        int size = 0;
//    }
}
